package com.ying.insure.health.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.ying.insure.health.entity.HealthEntity;
import com.ying.insure.health.service.HealthService;
import com.ying.common.utils.PageUtils;
import com.ying.common.utils.R;



/**
 * 
 *
 * @author ying
 * @email 1738063686@qq.com
 * @date 2020-05-19 00:22:25
 */
@RestController
@RequestMapping("health/health")
public class HealthController {
    @Autowired
    private HealthService healthService;

    /**
     * 分页查询
     */
    @GetMapping("/list")
    //@RequiresPermissions("health:health:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = healthService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 根据id查询
     */
    @GetMapping("/info/{id}")
    //@RequiresPermissions("health:health:info")
    public R info(@PathVariable("id") Integer id){
		HealthEntity health = healthService.getById(id);

        return R.ok().put("health", health);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    //@RequiresPermissions("health:health:save")
    public R save(HealthEntity health){
		healthService.save(health);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    //@RequiresPermissions("health:health:update")
    public R update(HealthEntity health){
		healthService.updateById(health);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    //@RequiresPermissions("health:health:delete")
    public R delete(Integer[] ids){
		healthService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
